package com.ctgu.computer.controller.admin;

import com.ctgu.computer.common.SuccessMessage;
import com.ctgu.computer.domain.po.ChargingPosition;
import com.ctgu.computer.domain.result.Result;
import com.ctgu.computer.service.MapService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/sys/admin/map")
@RequiredArgsConstructor
@Tag(name = "地图相关接口")
public class MapController {

    private final MapService mapService;

    @Operation(summary = "添加充电桩位置")
    @PostMapping("/ele/add")
    public Result addPoint(@RequestBody ChargingPosition chargingPosition){
        mapService.addCharingPosition(chargingPosition);
        return Result.success(SuccessMessage.ADD_SUCCESS,null);
    }

    @Operation(summary = "删除充电装位置" )
    @GetMapping("/ele/delete/{id}")
    public Result deletePoint(@PathVariable Integer id){
        mapService.deletePoint(id);
        return Result.success(SuccessMessage.DELETE_SUCCESS,null);
    }

    @Operation(summary = "更改充电桩的状态")
    @GetMapping("/ele/update/{id}")
    public Result updatePoint(@PathVariable Integer id){
        mapService.update(id);
        return Result.success(SuccessMessage.UPDATE_SUCCESS,null);
    }

    @Operation(summary = "获取所有充电柱位置")
    @GetMapping("/ele/get")
    public Result<List<ChargingPosition>> getPoint(){
        return Result.success(mapService.getAllCharging());
    }
}
